﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace drcoderz.com.clocks.chrono
{
    public class MiniClockMinute : Control
    {
        public MiniClockMinute()
        {
            this.DefaultStyleKey = typeof(MiniClockMinute);
        }

        private RotateTransform miniClockMinuteHand;

        public override void OnApplyTemplate()
        {
            miniClockMinuteHand = this.GetTemplateChild("miniClockMinuteHand") as RotateTransform;

            base.OnApplyTemplate();
        }

        public Brush HandColor
        {
            get { return (Brush)GetValue(HandColorProperty); }
            set { SetValue(HandColorProperty, value); }
        }

        // Using a DependencyProperty as the backing store for HandColor.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty HandColorProperty =
            DependencyProperty.Register("HandColor", typeof(Brush), typeof(MiniClockMinute), new PropertyMetadata(new SolidColorBrush(Colors.Red)));

        public int Value
        {
            get { return (int)GetValue(ValueProperty); }
            set { 
                SetValue(ValueProperty, value);
                if (miniClockMinuteHand != null)
                    miniClockMinuteHand.Angle = value;
            }
        }

        // Using a DependencyProperty as the backing store for Value.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(int), typeof(MiniClockMinute), new PropertyMetadata(null));
    }
}
